<template>
    <div class="root">
        <div class="top">
            <img src="../assets/logo.png" alt="read">
            <span class="pro-name">lib-web</span>
        </div>
        <div class="bottom" style="flex-grow: 1;">
            <el-menu class="nav"
                style="border: none;"
                @open="handleOpen"
                @close="handleClose">
                <div v-for="item in menuList" :key="item.id">
                    <el-menu-item :index="item.id" @click="activeIndex(item.name)">
                        <span>
                            <i :class="item.icon" style="margin-bottom: 1px;"></i>
                        </span>
                        <span slot="title">
                            <router-link :to="item.url" class="link-style">{{ item.name }}</router-link>
                        </span>
                    </el-menu-item>
                </div>
                <!-- <el-submenu index="4">
                    <template slot="title">
                        <i class="el-icon-location"></i>
                        <span>其他</span>
                    </template>
                    <el-menu-item-group>
                        <template slot="title">分组一</template>
                        <el-menu-item index="1-1">选项1</el-menu-item>
                        <el-menu-item index="1-2">选项2</el-menu-item>
                    </el-menu-item-group>
                    <el-menu-item-group title="分组2">
                        <el-menu-item index="1-3">选项3</el-menu-item>
                    </el-menu-item-group>
                    <el-submenu index="1-4">
                        <template slot="title">选项4</template>
                        <el-menu-item index="1-4-1">选项1</el-menu-item>
                    </el-submenu>
                </el-submenu> -->
            </el-menu>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        menuList: {
            type: Array,
            required: true
        }
    },
    data() {
        return {
            
        }
    },
    methods: {
        handleOpen(key, keyPath) {
            console.log(key, keyPath);
        },
        handleClose(key, keyPath) {
            console.log(key, keyPath);
        },
        activeIndex(name) {
            const value = name;
            this.$emit('headTitle', value);
        }
    }
}
</script>

<style scoped>
    .root {
        /* height: 100%; */
        display: flex;
        flex-direction: column;
        height: 100vh; /* 设置父容器的高度，这里使用了视口高度 */
    }

    .top {
        height: 50px;
        width: 130px;
        padding: 20px;
        margin: 0 auto;
        text-align: center;
    }

    .top>img {
        float: left;
        width: 50px;
    }

    .top .pro-name {
        line-height: 50px;
        font-size: 16px;
        font-weight: 600;
        font-family: Lobster, cursive;
    }

    .link-style {
        color: black;
        font-weight: 600;
        text-decoration: none;
    }

    .el-menu-item.is-active i {
        color: #6777ef;
    }
</style>